home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
doitk.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
64KB
|
2,012 lines
IMPLEMENTATION MODULE DoITK;
FROM SYSTEM IMPORT ADDRESS, ADR, TSIZE, CADR, ASSEMBLER, CALLSYS;
(* MM2-Module *)
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
IMPORT Block, BinOps, Lists, Strings, StrConv, GrafBase;
FROM Characters IMPORT CR, LF, SUB;
(* Magic-Module *)
IMPORT MagicStrings, MagicAES, mtTextfiles, mtAppl, mtUtils, mtDials,
MagicDOS, mtAlerts;
FROM MagicAES IMPORT GBOX, GIMAGE, GIBOX, GBUTTON, GSTRING,
SELECTABLE, DEFAULT, Exit, LASTOB, OUTLINED,
DRAW3D, SHADOWED, OBJECT, GrafMkstate,
PtrBITBLK, GICON, FL3DBAK;
FROM MagicSys IMPORT Nil, Null, Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6,
Bit7, Bit8, Bit9, Bit10, Bit11, Bit12, Bit13, Bit14,
Bit15;
(* CAT-Module *)
FROM Void IMPORT v;
IMPORT CatGlobal, CatTypes, Infofiles, MTE, MausTauschrsc, ListHelp,
ListDl, WinDials, grin, WdwManager, ConvertDate, MTPaths,
CatUtil, ConfVars, Varnames, UserInformation, CatHelp,
QuickSort, Protokoll;
CONST
maxInternalCmds = 8;
TYPE
tIntCmdType = RECORD
intIdent : INTEGER;
intVersion : INTEGER;
END;
tInternalCmds = ARRAY [0..maxInternalCmds-1] OF tIntCmdType;
MidTextPtr = POINTER TO ARRAY [0..MAX(INTEGER)] OF CHAR;
tCmdType = (tcSingle, (* TE *)
tcMultiple, (* TB *)
tcConfig); (* TK *)
tParamType = (tpConst, (* C *)
tpEnum, (* FA *) (* Buttons *)
tpEnumSet, (* FM *) (* Buttons *)
tpMTDate, (* FD *) (* Editfeld *)
tpDate, (* Fd *) (* Editfeld *)
tpString, (* FS *) (* Editfeld *)
tpPassword, (* FP *) (* Editfeld *)
tpNewPassword, (* Fp *) (* Editfeld *)
tpUsername, (* FU *) (* Editfeld, Button *)
tpInt, (* FI *) (* Editfeld num *)
tpRange, (* FIm,n *) (* Editfeld num *)
tpGroup, (* FG *) (* Editfeld, Button *)
tpChiefGroup); (* Fg *) (* Editfeld, Button *)
OneCommand =
RECORD
cmdName : CatTypes.String255; (* Name des Kommnandos *)
cmdHelp : MidTextPtr; (* Hilfetext zum Kommando,
* einzelne Zeilen mit CR/LF
* getrennt *)
cmdVersion : INTEGER; (* Versionsnummer des Kommandos *)
cmdIdent: INTEGER; (* Identifikationsnummer des Kommandos *)
cmdType : tCmdType; (* Kommandotyp *)
cmdParms: Lists.List; (* Liste der Parameter *)
cmdGroup: ARRAY[0..7] OF CHAR; (* Gruppe des Kommandos, Sortierkriterium *)
hasParms: BOOLEAN;
selected: BOOLEAN; (* Fr Darstellung in Listbox *)
END;
OneParam =
RECORD
paramName: CatTypes.String255;
paramHelp: MidTextPtr;
paramType: tParamType;
paramEnum: Lists.List;
paramDflt: CatTypes.String255; (* Default-Wert fr Parameter *)
paramMin : LONGINT; (* Min-Wert fr Integer-Bereich, ggf. Maxlnge des Strings *)
paramMax : LONGINT; (* Max-Wert fr Integer-Bereich *)
optional : BOOLEAN; (* Parameter ist optional *)
hasEnums : BOOLEAN; (* Hat Enum-Werte *)
obLow : INTEGER;
obHigh : INTEGER;
END;
OneEnum =
RECORD
enumName: CatTypes.String255; (* Kurzbeschreibung des Enum-Parameters *)
enumValue: CatTypes.String255; (* Werte dieses Enum-Parameters *)
obLow : INTEGER;
obHigh : INTEGER;
END;
(* Zeiger auf die Datentypen *)
pOneCommand = POINTER TO OneCommand;
pOneParam = POINTER TO OneParam;
pOneEnum = POINTER TO OneEnum;
CONST
internalCmds = tInternalCmds{
{1,0}, (* PMs anfordern *)
{2,0}, (* eigene PMs zurcksenden *)
{3,0}, (* PM-Status anfordern *)
{4,0}, (* ffentliche Mitteilungen anfordern *)
{5,0}, (* eigene ffentliche Mitteilungen zurcksenden *)
{6,0}, (* Gruppenumbenennungsinformationen anfordern *)
{8,0}, (* Maximalgre des Outfiles einstellen *)
{36,0} (* Gruppen bestellen/abstellen *)
};
CONST noITKAlert = "[1][CAT:|Das Infofile ITK steht nicht|zur Verfgung!][[OK]";
OkBut = "[OK";
CancelBut = "[Abbruch";
PreviewBut = "[Preview";
HelpBut = "Help";
eEnumCheck1 = "[3][CAT:|Aus der Aufzhlung|'";
eEnumCheck2 = "'|mu mindestens ein Wert|selektiert werden!][[OK]";
eEmptyParm1 = "[3][CAT:|Der Parameter|'";
eEmptyParm2 = "'|darf nicht leer sein!][[OK]";
eDateAlt1 = "[3][CAT:|Der Wert im Feld|'";
eDateAlt2 = "'|ist kein gltiges Datum!][[OK]";
eRangeAlt1 = "[3][CAT:|Der Wert im Feld|'";
eRangeAlt2 = "'|mu zwischen ";
eRangeAlt3 = " und ";
eRangeAlt4 = "|liegen!][[OK]";
eSaveCmd1 = "[2][CAT:|Soll die Einstellung fr das Kommando|'";
eSaveCmd2 = "'|dauerhaft gespeichert werden oder|soll es nur einmal gesendet werden?][[Speichern|[Einmal|:[Abbruch]";
eSaveConfig = "[2][CAT:|Die Konfiguration wurde gendert.|Damit diese Einstellung erhalten|bleibt, mssen die Optionen gesichert werden.|Optionen jetzt sichern?][[Speichern|:[Abbruch]";
eDataType = "[3][CAT:|In der ITK ist ein unbekannter|Datentyp bei Kommando & enthalten.][:[Abbruch]";
eUnknown = "[3][CAT:|Beim Parsen der ITK ist|ein unerwarteter Fehler aufgetreten.|Bitte schicken sie das ITK|an Dirk Steins @ K2][:[Abbruch]";
ePreview1 = "[1][CAT:|Das Kommando fr die MAUS sieht mit|den aktuellen Daten wie folgt aus:|'";
ePreview2 = "'][[OK]";
errMemErr = 2000;
errDataType = 2001;
VAR cmds : Lists.List;
globalLength : INTEGER;
CONST cMaxChars = 255; (* Maximale Zeichenzahl pro Zeile *)
cMaxText = 9; (* Maximale Anzahl Zeilen *)
cMaxButt = 4; (* Maximale Anzahl Buttons *)
cMaxIcon = 256; (* Maximale Anzahl Iconslots *)
cMaxTeds = 9; (* Maximale Anzahl Editfelder *)
CONST Box = 0;
Mover = 1;
Header = 2; (* berschrift *)
CONST Left = 0;
Center = 1;
Right = 2;
TYPE tString = ARRAY [0..cMaxChars-1] OF CHAR;
ShortKeys = ['A'..'Z'];
KeySet = SET OF ShortKeys;
VAR Tree: ARRAY [0..255] OF MagicAES.OBJECT;
Teds: ARRAY [0..cMaxTeds] OF MagicAES.TEDINFO;
Text: ARRAY [0..cMaxText] OF tString;
Button: ARRAY [0..cMaxButt] OF RECORD
text: tString;
objc: INTEGER;
END;
currObIdx: INTEGER;
tedIdx: INTEGER;
theTree: mtUtils.tObjcTree;
lastyPos: INTEGER;
globErr: INTEGER;
lastCmd: INTEGER;
helpButIdx: INTEGER;
okButIdx: INTEGER;
cancelButIdx: INTEGER;
previewButIdx: INTEGER;
usedKeys: KeySet;
CmdBox: ADDRESS;
(*----------------------------------------------------------------------
* Zusatzfunktionen fr die Listen
*----------------------------------------------------------------------*)
TYPE delEntryProc = PROCEDURE (VAR ADDRESS);
PROCEDURE DeleteSimpleList (VAR l: Lists.List; killCarrier: BOOLEAN;
deleteEntry : delEntryProc);
VAR entry: ADDRESS;
BEGIN
Lists.ResetList (l);
entry := Lists.PrevEntry (l);
WHILE entry # NIL DO
Lists.RemoveEntry (l, v.bool);
deleteEntry (entry);
entry := Lists.CurrentEntry (l);
END;
IF killCarrier THEN Lists.DeleteList (l, v.bool) END;
END DeleteSimpleList;
PROCEDURE delEnum (VAR entry : ADDRESS);
BEGIN
DEALLOCATE (entry, 0);
END delEnum;
PROCEDURE delParam (VAR entry : ADDRESS);
VAR pParam : pOneParam;
BEGIN
pParam := entry;
IF pParam^.hasEnums
THEN
DeleteSimpleList (pParam^.paramEnum, TRUE, delEnum);
END;
IF pParam^.paramHelp # NIL
THEN
DEALLOCATE (pParam^.paramHelp, 0);
END;
DEALLOCATE (entry, 0);
END delParam;
PROCEDURE delCmd (VAR entry : ADDRESS);
VAR pCmd : pOneCommand;
BEGIN
pCmd := entry;
IF pCmd^.hasParms
THEN
DeleteSimpleList (pCmd^.cmdParms, TRUE, delParam);
END;
IF pCmd^.cmdHelp # NIL
THEN
DEALLOCATE (pCmd^.cmdHelp, 0);
END;
DEALLOCATE (entry, 0);
END delCmd;
(*----------------------------------------------------------------------
* Interne Stringfunktionen
*----------------------------------------------------------------------*)
PROCEDURE StripShortcut (REF paramName: ARRAY OF CHAR;
VAR pName : ARRAY OF CHAR);
VAR p : INTEGER;
BEGIN
MagicStrings.Assign (paramName, pName);
p := Strings.Pos ("[", pName, 0);
IF p >= 0
THEN
MagicStrings.Delete (pName, p, 1);
END;
END StripShortcut;
(*----------------------------------------------------------------------
* Hilfe zu einem Kommando zusammenbauen
*----------------------------------------------------------------------*)
TYPE tHelpLine = ARRAY [0..70] OF CHAR;
pHelpLine = POINTER TO tHelpLine;
CONST helpLineLength = 65;
PROCEDURE AddToHelp (REF str: ARRAY OF CHAR; VAR helpList: Lists.List): BOOLEAN;
VAR helpLine : pHelpLine;
fromPos,
toPos : INTEGER;
BEGIN
IF str[0] # 0C
THEN
NEW (helpLine);
IF helpLine = NIL
THEN
MTE.noMemAlert();
DeleteSimpleList (helpList, TRUE, delEnum);
RETURN FALSE;
END;
fromPos := 0;
toPos := LENGTH (str);
WHILE (fromPos < toPos) DO
NEW (helpLine);
IF helpLine = NIL
THEN
MTE.noMemAlert();
DeleteSimpleList (helpList, TRUE, delEnum);
RETURN FALSE;
END;
IF toPos - fromPos > helpLineLength - 1
THEN
(* Umbruch an Wortgrenze durchfhren *)
toPos := fromPos + helpLineLength-1;
WHILE (str[toPos] # ' ') & (toPos > fromPos) DO DEC (toPos); END;
IF toPos = fromPos THEN toPos := fromPos + helpLineLength - 1 END;
END;
MagicStrings.Copy (str, fromPos, toPos - fromPos, helpLine^);
Lists.AppendEntry (helpList, helpLine, v.bool);
IF v.bool
THEN
MTE.noMemAlert();
DeleteSimpleList (helpList, TRUE, delEnum);
RETURN FALSE
END;
fromPos := toPos + 1;
toPos := LENGTH (str);
END;
END;
RETURN TRUE;
END AddToHelp;
PROCEDURE AddParmHelp (pParm: pOneParam; VAR helpList: Lists.List): BOOLEAN;
VAR pName : CatTypes.String255;
BEGIN
WITH pParm^ DO
IF paramHelp # NIL
THEN
StripShortcut (paramName, pName);
MagicStrings.Insert ("Parameter: ", pName, 0);
IF ~AddToHelp (pName, helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (" ", helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (paramHelp^, helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (" ", helpList)
THEN
RETURN FALSE
END;
END;
END;
RETURN TRUE;
END AddParmHelp;
PROCEDURE BuildHelp (pCmd: pOneCommand; VAR helpList: Lists.List): BOOLEAN;
VAR pParm : pOneParam;
BEGIN
WITH pCmd^ DO
Lists.CreateList (helpList, v.bool);
IF v.bool
THEN
MTE.noMemAlert();
RETURN FALSE;
END;
IF cmdHelp # NIL
THEN
IF ~AddToHelp (cmdName, helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (" ", helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (cmdHelp^, helpList)
THEN
RETURN FALSE
END;
IF ~AddToHelp (" ", helpList)
THEN
RETURN FALSE
END;
END;
IF hasParms
THEN
Lists.ResetList (cmdParms);
pParm := Lists.NextEntry (cmdParms);
WHILE pParm # NIL DO
IF ~AddParmHelp (pParm, helpList) THEN RETURN FALSE END;
pParm := Lists.NextEntry (cmdParms);
END;
END;
END;
RETURN TRUE;
END BuildHelp;
(*----------------------------------------------------------------------
* ITK Dialogboxen zusammenbauen
*----------------------------------------------------------------------*)
PROCEDURE SetObjc (objc, typ, x, y, w, h: INTEGER; f, s: BITSET;
spec: ADDRESS);
BEGIN
Tree[objc].obNext:= -1;
Tree[objc].obHead:= -1;
Tree[objc].obTail:= -1;
Tree[objc].obType:= typ;
Tree[objc].obFlags:= f;
Tree[objc].obState:= s;
Tree[objc].obSpec.address:= spec;
Tree[objc].obX:= x;
Tree[objc].obY:= y;
Tree[objc].obWidth:= w;
Tree[objc].obHeight:= h;
MagicAES.ObjcAdd (theTree, Box, objc);
Tree[Box].obWidth := BinOps.HigherInt (x+w, Tree[Box].obWidth);
Tree[Box].obHeight := BinOps.HigherInt (y+h, Tree[Box].obHeight);
END SetObjc;
PROCEDURE PrepareTree (VAR title: ARRAY OF CHAR);
BEGIN
theTree := ADR (Tree);
Tree[Box].obNext:= -1;
Tree[Box].obHead:= -1;
Tree[Box].obTail:= -1;
Tree[Box].obType:= GBOX;
Tree[Box].obFlags:= {FL3DBAK};
Tree[Box].obState:= {OUTLINED};
Tree[Box].obSpec.Box.char:= 0C;
Tree[Box].obSpec.Box.frame:= 2C;
(* Tree[Box].obSpec.Box.flags:= {Bit0,Bit11, Bit12}; *)
Tree[Box].obSpec.Box.flags:= {Bit11, Bit12};
Tree[Box].obX:= 0; Tree[Box].obY:= 0;
Tree[Box].obWidth:= 0;
Tree[Box].obHeight:= 0;
SetObjc (Mover, 1119H, 0, 0, 16, 16, {}, {OUTLINED}, Null);
Tree[Mover].obSpec.Box.char:= 0C;
Tree[Mover].obSpec.Box.frame:= 1C;
Tree[Mover].obSpec.Box.flags:= {Bit11, Bit12};
(* Titelzeile hinzufgen *)
SetObjc (Header, 131CH, 2 * mtAppl.CharWidth, mtAppl.CharHeight, INTEGER(LENGTH(title)) * mtAppl.CharWidth, 0, {}, {MagicAES.SHADOWED}, ADR(title));
currObIdx := Header+1;
tedIdx := 0;
lastyPos := currObIdx * mtAppl.CharHeight;
usedKeys := KeySet{'A','O','P'};
END PrepareTree;
PROCEDURE CalcCoords (REF text: ARRAY OF CHAR; VAR x, y, w, h: INTEGER);
BEGIN
h := mtAppl.CharHeight;
x := mtAppl.CharWidth * 2;
y := lastyPos + mtAppl.CharHeight;
lastyPos := y;
w := mtAppl.CharWidth * INTEGER(LENGTH (text)+4);
END CalcCoords;
PROCEDURE CalcCoords2 (REF name: ARRAY OF CHAR; maxLen: INTEGER; VAR x, y, w, h: INTEGER);
BEGIN
DEC (lastyPos, mtAppl.CharHeight);
CalcCoords (name, x, y, w, h);
x := x + w - 2 * mtAppl.CharWidth;
IF maxLen > 50
THEN
maxLen := 50;
END;
IF maxLen = 0
THEN
maxLen := 50;
END;
w := mtAppl.CharWidth * (maxLen + 1);
END CalcCoords2;
PROCEDURE CalcEdButCoords (maxLen: INTEGER; VAR x, y, w, h: INTEGER);
BEGIN
x := x + w + 2 * mtAppl.CharWidth;
IF maxLen > 50
THEN
maxLen := 50;
END;
IF maxLen = 0
THEN
maxLen := 50;
END;
w := mtAppl.CharWidth * (maxLen + 4);
END CalcEdButCoords;
PROCEDURE AddShortcut (VAR name: ARRAY OF CHAR);
VAR l : CARDINAL;
i : CARDINAL;
ch: CHAR;
BEGIN
l := LENGTH (name);
i := 0;
ch := CAP (name[i]);
WHILE (i < l) &
((ch IN usedKeys) OR (ch < 'A') OR (ch > 'Z'))
DO
INC (i);
ch := CAP (name[i]);
END;
IF (i < l)
THEN
(* freien Shortcut gefunden *)
INCL (usedKeys, ch);
MagicStrings.Insert ("[", name, i);
END;
END AddShortcut;
PROCEDURE AddCheckButton (VAR name: ARRAY OF CHAR; threeState: BOOLEAN): INTEGER;
(* Check: Ext 18
* Three: Ext 23
*)
VAR obType : CARDINAL; (* Vereinigt normalen und erweiterten Objekttyp *)
x, y, w, h : INTEGER;
BEGIN
IF threeState
THEN
obType := mtDials.ThreeState * 256 + MagicAES.GBUTTON;
ELSE
obType := mtDials.SpecButton * 256 + MagicAES.GBUTTON;
END;
CalcCoords (name, x, y, w, h);
AddShortcut (name);
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE}, {}, ADR(name));
INC (currObIdx);
RETURN currObIdx - 1;
END AddCheckButton;
PROCEDURE AddRadioButton (parent: INTEGER; VAR name: ARRAY OF CHAR): INTEGER;
(* Check: Ext 18
* Three: Ext 23
*)
VAR obType : CARDINAL; (* Vereinigt normalen und erweiterten Objekttyp *)
x, y, w, h : INTEGER;
BEGIN
obType := mtDials.SpecButton * 256 + MagicAES.GBUTTON;
CalcCoords (name, x, y, w, h);
AddShortcut (name);
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.RBUTTON}, {}, ADR(name));
(* Tree[currObIdx].obHead := parent; *)
INC (currObIdx);
RETURN currObIdx - 1;
END AddRadioButton;
(*
PROCEDURE AddParent (): INTEGER;
BEGIN
obType := MagicAES.GIBOX;
CalcCoords3 (x, y, w, h);
SetObjc (currObIdx, obType, x, y, w, h, {}, {}, Null);
INC (currObIdx);
RETURN currObIdx - 1;
END AddParent;
*)
PROCEDURE AddText (VAR name: ARRAY OF CHAR): INTEGER;
(* Check: Ext 18
* Three: Ext 23
*)
VAR obType : CARDINAL; (* Vereinigt normalen und erweiterten Objekttyp *)
x, y, w, h : INTEGER;
BEGIN
obType := MagicAES.GSTRING;
CalcCoords (name, x, y, w, h);
SetObjc (currObIdx, obType, x, y, w, h, {}, {}, ADR(name));
INC (currObIdx);
RETURN currObIdx - 1;
END AddText;
PROCEDURE PrepareEdit (isNum: BOOLEAN; maxLength: INTEGER; REF default: ARRAY OF CHAR;
VAR obType: CARDINAL);
VAR validChar : CHAR;
i : INTEGER;
BEGIN
IF (maxLength = 0) & ~isNum
THEN
maxLength := 255;
ELSIF (maxLength = 0) & isNum
THEN
maxLength := 10;
END;
IF (maxLength > 50) & ~isNum
THEN
obType := mtDials.LongEdit * 256 + MagicAES.GFTEXT;
ELSE
obType := MagicAES.GFTEXT;
END;
WITH Teds[tedIdx] DO
ALLOCATE (tePtext, maxLength + 1);
ALLOCATE (tePvalid, maxLength + 1);
ALLOCATE (tePtmplt, maxLength + 1);
teFont := MagicAES.IBM;
teFontid := 0;
teJust := 0;
teColor := INTEGER({Bit7, Bit8});
teFontsize := 0;
teThickness := 0;
teTxtlen := maxLength;
teTmplen := maxLength;
MagicStrings.Assign (default, tePtext^);
IF isNum
THEN
validChar := '9';
ELSE
validChar := 'X';
END;
FOR i := 0 TO maxLength - 1 DO
tePvalid^[i] := validChar;
tePtmplt^[i] := '_';
END;
tePvalid^[maxLength] := 0C;
tePtmplt^[maxLength] := 0C;
END;
END PrepareEdit;
PROCEDURE AddEditField (VAR name: ARRAY OF CHAR; isNum: BOOLEAN;
maxLength: INTEGER; REF default: ARRAY OF CHAR): INTEGER;
VAR obType : CARDINAL;
x, y, w, h : INTEGER;
BEGIN
PrepareEdit (isNum, maxLength, default, obType);
v.int := AddText (name);
CalcCoords2 (name, maxLength, x, y, w, h);
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.EDITABLE}, {}, ADR(Teds[tedIdx]));
INC (tedIdx);
INC (currObIdx);
RETURN currObIdx - 1;
END AddEditField;
PROCEDURE AddHelpBut(x, y, w, h : INTEGER);
BEGIN
WITH Teds[tedIdx] DO
ALLOCATE (tePtext, LENGTH (HelpBut)+1);
tePvalid := NIL;
tePtmplt := NIL;
teFont := MagicAES.SMALL;
teFontid := 0;
teJust := 2;
teColor := INTEGER({Bit7, Bit8, Bit12});
teFontsize := 0;
teThickness := -1;
teTxtlen := LENGTH (HelpBut);
teTmplen := 0;
MagicStrings.Assign (HelpBut, tePtext^);
END;
SetObjc (currObIdx, MagicAES.GBOXTEXT, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.Exit, Bit15}, {MagicAES.OUTLINED, MagicAES.SHADOWED}, ADR(Teds[tedIdx]));
INC (tedIdx);
helpButIdx := currObIdx;
INC (currObIdx);
END AddHelpBut;
PROCEDURE AddExitButs();
VAR obType : CARDINAL;
x, y, w, h : INTEGER;
BEGIN
(* Hilfe-, Preview-, OK- und Abbruch-Button hinzufgen *)
(* Es werden zwei Reihen hinzugefgt, in der oberen der Hilfe-
* und der OK-Button, jeweils darunter der Preview- und Abbruch-
* Button. Das sieht dann ungefhr so aus:
*
* | +------------+ +-------------+ |
* | | Help | | OK | |
* | +------------+ +-------------+ |
* | |
* | +------------+ +-------------+ |
* | | Preview | | Abbruch | |
* | +------------+ +-------------+ |
* +-------------------------------------------------------+
*
*)
(* Breite um fnf Zeichen vergrern *)
Tree[Box].obWidth := Tree[Box].obWidth + 5 * mtAppl.CharWidth;
obType := mtDials.SpecButton * 256 + MagicAES.GBUTTON;
(* Position berechnen *)
h := mtAppl.CharHeight;
w := mtAppl.CharWidth * INTEGER(LENGTH (CancelBut)+2);
Tree[Box].obWidth := BinOps.HigherInt (Tree[Box].obWidth, 2 * w + 6 * mtAppl.CharWidth);
x := 2 * mtAppl.CharWidth;
y := lastyPos + 2 * mtAppl.CharHeight;
(* Hilfebutton hinzufgen *)
AddHelpBut (x, y, w, h);
x := Tree[Box].obWidth - 2 * mtAppl.CharWidth - w;
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.DEFAULT, MagicAES.Exit}, {}, CADR(OkBut));
okButIdx := currObIdx;
INC (currObIdx);
(* Jetzt Preview- und Abbruch-Button *)
(* Previewbutton *)
x := 2 * mtAppl.CharWidth;
y := lastyPos + 4 * mtAppl.CharHeight;
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.Exit}, {}, CADR(PreviewBut));
previewButIdx := currObIdx;
INC (currObIdx);
(* OK-Button *)
x := Tree[Box].obWidth - 2 * mtAppl.CharWidth - w;
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.Exit, Bit14, MagicAES.LASTOB}, {}, CADR(CancelBut));
cancelButIdx := currObIdx;
INC (currObIdx);
Tree[Box].obHeight := lastyPos + 6 * mtAppl.CharHeight;
END AddExitButs;
PROCEDURE AddGroupSelect (VAR name: ARRAY OF CHAR; chiefGroup: BOOLEAN;
maxLength: INTEGER; REF default: ARRAY OF CHAR): INTEGER;
VAR obType : CARDINAL;
state : BITSET;
x, y, w, h : INTEGER;
BEGIN
(* Button mit Bit fr Groupselect gesetzt *)
obType := mtDials.SpecButton * 256 + MagicAES.GBUTTON;
IF chiefGroup
THEN
state := {Bit14};
ELSE
state := {Bit15};
END;
CalcCoords (name, x, y, w, h);
AddShortcut (name);
IF (currObIdx > Header+1)
THEN
INC (y, mtAppl.CharHeight);
INC (lastyPos, mtAppl.CharHeight);
END;
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.Exit}, state, ADR(name));
INC (currObIdx);
(* Editfeld hinzufgen *)
PrepareEdit (FALSE, maxLength, default, obType);
CalcEdButCoords (maxLength, x, y, w, h);
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.EDITABLE}, {}, ADR(Teds[tedIdx]));
INC (tedIdx);
INC (currObIdx);
INC (lastyPos, mtAppl.CharHeight);
RETURN currObIdx - 1;
END AddGroupSelect;
PROCEDURE AddUserSelect (VAR name: ARRAY OF CHAR; maxLength: INTEGER; REF default: ARRAY OF CHAR): INTEGER;
VAR obType : CARDINAL;
x, y, w, h : INTEGER;
defName : CatTypes.String255;
botWdw : INTEGER;
BEGIN
(* Button mit Bit fr Groupselect gesetzt *)
obType := mtDials.SpecButton * 256 + MagicAES.GBUTTON;
CalcCoords (name, x, y, w, h);
AddShortcut (name);
IF (currObIdx > Header+1)
THEN
INC (y, mtAppl.CharHeight);
INC (lastyPos, mtAppl.CharHeight);
END;
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.SELECTABLE, MagicAES.Exit}, {Bit13}, ADR(name));
INC (currObIdx);
(* Editfeld hinzufgen *)
IF default[0] = 0C
THEN
(* Aktuellen User abfragen *)
IF grin.grinWindowTop (WdwManager.ownTopWindow)
THEN
grin.ActualFrom (WdwManager.ownTopWindow, defName);
ELSIF (WdwManager.GetSecondWdw (botWdw)
& grin.grinWindowTop (botWdw)) OR
grin.grinOnlyOneWind (botWdw)
THEN
grin.ActualFrom (botWdw, defName);
END;
PrepareEdit (FALSE, maxLength, defName, obType);
ELSE
PrepareEdit (FALSE, maxLength, default, obType);
END;
CalcEdButCoords (maxLength, x, y, w, h);
SetObjc (currObIdx, obType, x, y, w, h, {MagicAES.EDITABLE}, {}, ADR(Teds[tedIdx]));
INC (tedIdx);
INC (currObIdx);
INC (lastyPos, mtAppl.CharHeight);
RETURN currObIdx - 1;
END AddUserSelect;
PROCEDURE AddRadioEnums (paramEnums: Lists.List);
VAR pEnum : pOneEnum;
count : INTEGER;
BEGIN
count := Lists.NoOfEntries (paramEnums);
Lists.ResetList (paramEnums);
pEnum := Lists.NextEntry (paramEnums);
WHILE pEnum # NIL DO
IF count = 1
THEN
pEnum^.obLow := AddCheckButton (pEnum^.enumName, FALSE);
ELSE
pEnum^.obLow := AddRadioButton (Box, pEnum^.enumName);
END;
pEnum := Lists.NextEntry (paramEnums);
END;
END AddRadioEnums;
PROCEDURE CheckEnumValue (REF str: ARRAY OF CHAR): INTEGER;
VAR count: INTEGER;
pos : INTEGER;
BEGIN
pos := 0;
count := 0;
WHILE pos >= 0 DO
pos := Strings.Pos (":", str, pos);
IF pos >= 0 THEN INC (pos) END;
INC (count);
END;
RETURN count;
END CheckEnumValue;
PROCEDURE AddCheckEnums (paramEnums: Lists.List);
VAR pEnum : pOneEnum;
count : INTEGER;
BEGIN
Lists.ResetList (paramEnums);
pEnum := Lists.NextEntry (paramEnums);
WHILE pEnum # NIL DO
count := CheckEnumValue (pEnum^.enumValue);
IF count < 3
THEN
pEnum^.obLow := AddCheckButton (pEnum^.enumName, FALSE);
ELSIF count = 3
THEN
pEnum^.obLow := AddCheckButton (pEnum^.enumName, TRUE);
ELSE
(* Nicht behandelbar momentan *)
END;
pEnum := Lists.NextEntry (paramEnums);
END;
END AddCheckEnums;
PROCEDURE AddParamObjcs (pParam: pOneParam);
BEGIN
WITH pParam^ DO
CASE paramType OF
tpConst : RETURN; |
tpEnum : IF hasEnums
THEN
AddRadioEnums (paramEnum);
END; |
tpEnumSet : IF hasEnums
THEN
AddCheckEnums (paramEnum);
END; |
tpMTDate,
tpDate : obLow := AddEditField (paramName, FALSE, 12, paramDflt); |
tpString,
tpPassword,
tpNewPassword:
obLow := AddEditField (paramName, FALSE, SHORT(paramMin), paramDflt); |
tpInt,
tpRange: obLow := AddEditField (paramName, TRUE, 10, paramDflt); |
tpGroup,
tpChiefGroup:
(* Button und dahinter Editfeld *)
obLow := AddGroupSelect (paramName, paramType = tpChiefGroup,
SHORT(paramMin), paramDflt); |
tpUsername:
(* Button und dahinter Editfeld *)
obLow := AddUserSelect (paramName, SHORT(paramMin), paramDflt); |
ELSE
END;
END;
END AddParamObjcs;
PROCEDURE BuildTree (VAR pCmd : pOneCommand);
VAR pParam : pOneParam;
BEGIN
WITH pCmd^ DO
PrepareTree (cmdName);
IF hasParms
THEN
Lists.ResetList (cmdParms);
pParam := Lists.NextEntry (cmdParms);
WHILE pParam # NIL DO
AddParamObjcs (pParam);
pParam := Lists.NextEntry (cmdParms);
END;
END;
AddExitButs();
(* Mover noch verschieben *)
Tree[Mover].obX:= Tree[Box].obWidth - Tree[Mover].obWidth;
END;
END BuildTree;
PROCEDURE RemoveTree ();
(* Allozierten Speicher fr Editfelder wieder freigeben *)
VAR i : INTEGER;
BEGIN
FOR i := 0 TO tedIdx - 1 DO
WITH Teds[i] DO
DEALLOCATE (tePtext, 0);
DEALLOCATE (tePvalid, 0);
DEALLOCATE (tePtmplt, 0);
END;
END;
END RemoveTree;
(*----------------------------------------------------------------------
* ITK Werte aus Dialogbox auslesen
*----------------------------------------------------------------------*)
PROCEDURE GetEnumValue (idx: INTEGER; REF str: ARRAY OF CHAR;
VAR target: ARRAY OF CHAR);
VAR count : INTEGER;
lastPos : INTEGER;
pos : INTEGER;
val : CatTypes.String255;
BEGIN
lastPos := 0;
pos := 0;
count := 0;
WHILE (pos >= 0) DO
pos := Strings.Pos (":", str, lastPos);
IF (count = idx) & (pos > 0)
THEN
MagicStrings.Copy (str, lastPos, pos - lastPos, val);
MagicStrings.Append (val, target);
RETURN
END;
IF (pos < 0) & (count = idx)
THEN
(* letzter Parameter oder nur ein Wert *)
MagicStrings.Copy (str, lastPos, INTEGER(LENGTH (str)) - lastPos, val);
MagicStrings.Append (val, target);
(* MagicStrings.Append (str, target); *)
RETURN
END;
lastPos := pos+1;
INC (count);
END;
END GetEnumValue;
PROCEDURE CheckRadioEnums (paramEnums: Lists.List; VAR str: ARRAY OF CHAR): BOOLEAN;
VAR pEnum : pOneEnum;
count : INTEGER;
BEGIN
count := Lists.NoOfEntries (paramEnums);
Lists.ResetList (paramEnums);
pEnum := Lists.NextEntry (paramEnums);
WHILE pEnum # NIL DO
IF mtUtils.InState (theTree, pEnum^.obLow, MagicAES.SELECTED)
THEN
(* Ersten Wert aus Aufzhlung nehmen! *)
GetEnumValue (0, pEnum^.enumValue, str);
RETURN TRUE;
ELSIF count = 1
THEN
(* Zweiten Wert aus Aufzhlung nehmen! *)
GetEnumValue (1, pEnum^.enumValue, str);
RETURN TRUE;
END;
pEnum := Lists.NextEntry (paramEnums);
END;
(* Hier kommen wir nur hier, wenn keiner selektiert ist *)
RETURN count = 1;
END CheckRadioEnums;
PROCEDURE CheckCheckEnums (paramEnums: Lists.List; VAR str: ARRAY OF CHAR): BOOLEAN;
VAR pEnum : pOneEnum;
count : INTEGER;
oneSet: BOOLEAN;
value : INTEGER;
BEGIN
Lists.ResetList (paramEnums);
oneSet := FALSE;
pEnum := Lists.NextEntry (paramEnums);
WHILE pEnum # NIL DO
count := CheckEnumValue (pEnum^.enumValue);
IF count < 3
THEN
IF mtUtils.InState (theTree, pEnum^.obLow, MagicAES.SELECTED)
THEN
GetEnumValue (0, pEnum^.enumValue, str);
oneSet := TRUE;
END;
ELSIF count = 3
THEN
value := mtUtils.GetThreeState (theTree, pEnum^.obLow);
IF value = mtUtils.CLEAR
THEN
(* zweiten Wert aus Enum nehmen *)
GetEnumValue (1, pEnum^.enumValue, str);
oneSet := TRUE;
ELSIF value = mtUtils.SETNEW
THEN
(* ersten Wert aus Enum nehmen *)
GetEnumValue (0, pEnum^.enumValue, str);
oneSet := TRUE;
END;
ELSE
(* Nicht behandelbar momentan *)
END;
pEnum := Lists.NextEntry (paramEnums);
END;
RETURN oneSet;
END CheckCheckEnums;
PROCEDURE GetParam (pParm: pOneParam; VAR str: ARRAY OF CHAR): BOOLEAN;
VAR bRes : BOOLEAN;
value : CatTypes.String255;
dt : ConvertDate.Date;
temp : CatTypes.String127;
lIntVal : LONGINT;
pos : CARDINAL;
pName : CatTypes.String127;
BEGIN
WITH pParm^ DO
CASE paramType OF
tpConst : (* Konstanten Teil bernehmen *)
MagicStrings.Append (paramDflt, str);
RETURN TRUE; |
tpEnum : IF hasEnums
THEN
bRes := CheckRadioEnums (paramEnum, str);
IF ~bRes
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eEnumCheck1, pName, eEnumCheck2);
RETURN FALSE;
END;
END;
RETURN TRUE; |
tpEnumSet : IF hasEnums
THEN
bRes := CheckCheckEnums (paramEnum, str);
IF ~bRes
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eEnumCheck1, pName, eEnumCheck2);
RETURN FALSE;
END;
END;
RETURN TRUE; |
tpMTDate,
tpDate : (* Editfeld auslesen *)
mtUtils.ObjcString (theTree, obLow, value);
IF (value[0] = 0C)
THEN
IF ~optional
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eEmptyParm1, pName, eEmptyParm2);
RETURN FALSE;
END;
ELSIF ~ConvertDate.DateOk (value)
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eDateAlt1, pName, eDateAlt2);
RETURN FALSE;
ELSE
(* Datum konvertieren *)
IF paramType = tpMTDate
THEN
ConvertDate.StrToMTDate (value, temp);
ELSE
ConvertDate.TextToDate (value, dt, v.bool);
ConvertDate.DateToText (dt, "DD.MM.YYYY", temp);
END;
MagicStrings.Append (temp, str);
END;
RETURN TRUE; |
tpUsername,
tpGroup,
tpChiefGroup,
tpString,
tpPassword,
tpNewPassword:
mtUtils.ObjcString (theTree, obLow, value);
Strings.DelLeadingBlanks (value);
Strings.DelTrailingBlanks (value);
IF (value[0] = 0C)
THEN
IF ~optional
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eEmptyParm1, pName, eEmptyParm2);
RETURN FALSE;
END;
ELSE
MagicStrings.Append (value, str);
END;
RETURN TRUE; |
tpInt,
tpRange: mtUtils.ObjcString (theTree, obLow, value);
Strings.DelBlanks (value);
IF (value[0] = 0C)
THEN
IF ~optional
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MTE.InfoAlert (eEmptyParm1, pName, eEmptyParm2);
RETURN FALSE;
END;
ELSE
pos := 0;
lIntVal := StrConv.StrToLInt (value, pos, v.bool);
IF paramType = tpRange
THEN
IF (lIntVal < paramMin) OR (lIntVal > paramMax)
THEN
(* Fehlermeldung *)
StripShortcut (paramName, pName);
MagicStrings.Assign (eRangeAlt1, value);
MagicStrings.Append (pName, value);
MagicStrings.Append (eRangeAlt2, value);
MagicStrings.Append (StrConv.IntToStr (paramMin, 0), value);
MagicStrings.Append (eRangeAlt3, value);
MagicStrings.Append (StrConv.IntToStr (paramMax, 0), value);
MagicStrings.Append (eRangeAlt4, value);
MTE.info (value);
RETURN FALSE;
END;
END;
IF lIntVal >= 0
THEN
MagicStrings.Assign ("+", value);
ELSE
MagicStrings.Assign ("", value);
END;
MagicStrings.Append (StrConv.IntToStr (lIntVal, 0), value);
MagicStrings.Append (value, str);
END;
RETURN TRUE; |
ELSE
END;
END;
RETURN TRUE;
END GetParam;
PROCEDURE WriteCmdToFile (REF str: ARRAY OF CHAR);
VAR fName : CatTypes.String255;
fHdl : mtTextfiles.TEXTFILE;
BEGIN
IF str[0] = 0C THEN RETURN END;
MagicStrings.Assign (MTPaths.MessagePath, fName);
MagicStrings.Append (CatTypes.userCmdFile, fName);
IF mtTextfiles.OpenTextfile (fName, mtTextfiles.APPEND, 512, fHdl)
OR mtTextfiles.OpenTextfile (fName, mtTextfiles.WRITE, 512, fHdl)
THEN
mtTextfiles.WriteChar (fHdl, ':');
mtTextfiles.WriteLine (fHdl, str);
mtTextfiles.WriteLn (fHdl);
mtTextfiles.CloseTextfile (fHdl);
Protokoll.SendPathUpdate (MTPaths.MessagePath);
ELSE
MTE.InfoAlert (MTE.noFile1, fName, MTE.noFile3);
END;
END WriteCmdToFile;
PROCEDURE GetValues (pCmd: pOneCommand; doWrite: BOOLEAN; preview: BOOLEAN): BOOLEAN;
VAR pParm : pOneParam;
str : CatTypes.String1023;
tmp : CatTypes.String255;
BEGIN
(* Parameter und Objekte auslesen und prfen *)
MagicStrings.Assign ("",str);
WITH pCmd^ DO
IF hasParms
THEN
Lists.ResetList (cmdParms);
pParm := Lists.NextEntry (cmdParms);
WHILE pParm # NIL DO
IF ~GetParam (pParm, str)
THEN
RETURN FALSE
END;
pParm := Lists.NextEntry (cmdParms);
END;
IF doWrite
THEN
IF cmdType = tcConfig
THEN
(* Abfragen, ob es gespeichert oder nur einmal geschrieben werden soll *)
MagicStrings.Assign (eSaveCmd1, tmp);
MagicStrings.Append (cmdName, tmp);
MagicStrings.Append (eSaveCmd2, tmp);
v.int := mtAlerts.Alert (1, tmp);
IF v.int = 1
THEN
(* Sichern in CATUSER.INF *)
MagicStrings.Assign (cItkCmd, tmp);
MagicStrings.Append (StrConv.IntToStr (cmdIdent, 0), tmp);
v.bool := ConfVars.SetConfigString (tmp, str);
MagicStrings.Assign (cItkCmdVersion, tmp);
MagicStrings.Append (StrConv.IntToStr (cmdIdent, 0), tmp);
v.bool := ConfVars.SetConfigInt (tmp, cmdVersion);
ConfVars.GetConfDefInt (cItkCmdMax, v.int, -1);
IF v.int < cmdIdent
THEN
v.bool := ConfVars.SetConfigInt (cItkCmdMax, cmdIdent);
END;
IF ~UserInformation.UserBLK.autosave
THEN
v.int := mtAlerts.Alert (1, eSaveConfig);
IF v.int = 1
THEN
CatUtil.WriteUserBlock();
END;
END;
ELSIF v.int = 2
THEN
WriteCmdToFile (str);
END;
ELSE
WriteCmdToFile (str);
END;
END;
IF preview
THEN
MTE.InfoAlert (ePreview1, str, ePreview2);
END;
END;
END;
RETURN TRUE;
END GetValues;
(*----------------------------------------------------------------------
* Parser fr das ITK
*----------------------------------------------------------------------*)
PROCEDURE ParseDataType (REF typeStr : ARRAY OF CHAR; VAR param: OneParam): BOOLEAN;
VAR pos : CARDINAL;
BEGIN
pos := 1;
CASE typeStr[0] OF
'A' : param.paramType := tpEnum; |
'M' : param.paramType := tpEnumSet; |
'D' : param.paramType := tpMTDate; |
'd' : param.paramType := tpDate; |
'S',
'P',
'p' : CASE typeStr[0] OF
'S' : param.paramType := tpString; |
'P' : param.paramType := tpPassword; |
'p' : param.paramType := tpNewPassword; |
ELSE
END;
(* Maxlnge auslesen *)
param.paramMin := StrConv.StrToLInt (typeStr, pos, v.bool); |
'U' : param.paramType := tpUsername; |
'I' : IF Strings.Pos (',', typeStr, pos) > 0
THEN
param.paramType := tpRange;
(* Direkt aufsplitten und Min und Max rauslesen *)
param.paramMin := StrConv.StrToLInt (typeStr, pos, v.bool);
INC (pos); (* Komma berspringen *)
param.paramMax := StrConv.StrToLInt (typeStr, pos, v.bool);
ELSE
param.paramType := tpInt;
END; |
'G' : param.paramType := tpGroup; |
'g' : param.paramType := tpChiefGroup; |
ELSE
globErr := errDataType;
RETURN FALSE;
END;
param.optional := typeStr[pos] = 'o';
RETURN TRUE;
END ParseDataType;
PROCEDURE WriteParam (VAR cConstant, cDataType: ARRAY OF CHAR;
VAR cParam: OneParam;
VAR cCmd : OneCommand;
VAR paramDataDa : BOOLEAN): BOOLEAN;
VAR pParam : pOneParam;
BEGIN
IF cConstant[0] # ""
THEN
cParam.paramType := tpConst;
MagicStrings.Assign (cConstant, cParam.paramDflt);
END;
ALLOCATE (pParam, TSIZE (OneParam));
IF pParam = NIL
THEN
RETURN FALSE
END;
(* Inhalt kopieren *)
pParam^ := cParam;
(* An Liste anhngen *)
Lists.AppendEntry (cCmd.cmdParms, pParam, v.bool);
(* Daten zurcksetzen *)
paramDataDa := FALSE;
MagicStrings.Assign ("", cConstant);
MagicStrings.Assign ("", cDataType);
MagicStrings.Assign ("", cParam.paramName);
MagicStrings.Assign ("", cParam.paramDflt);
cParam.paramMin := 0;
cParam.paramMax := 0;
cParam.optional := FALSE;
cParam.paramHelp := NIL;
cParam.hasEnums := FALSE;
(* Und Returncode von AppendEntry zurckgeben *)
RETURN ~v.bool;
END WriteParam;
PROCEDURE WriteEnumData (VAR param: OneParam; VAR enum: OneEnum;
VAR enumDataDa: BOOLEAN): BOOLEAN;
VAR pEnum : pOneEnum;
BEGIN
ALLOCATE (pEnum, TSIZE (OneEnum));
IF pEnum = NIL
THEN
RETURN FALSE;
END;
(* Inhalt kopieren *)
pEnum^ := enum;
(* An Liste anhngen *)
Lists.AppendEntry (param.paramEnum, pEnum, v.bool);
MagicStrings.Assign ("", enum.enumName);
MagicStrings.Assign ("", enum.enumValue);
enumDataDa := FALSE;
RETURN ~v.bool;
END WriteEnumData;
PROCEDURE IsInternalCmd (VAR cCmd : OneCommand): BOOLEAN;
VAR i : INTEGER;
BEGIN
FOR i := 0 TO maxInternalCmds - 1 DO
IF (cCmd.cmdIdent = internalCmds[i].intIdent)
& (cCmd.cmdVersion = internalCmds[i].intVersion)
THEN
RETURN TRUE;
END;
END;
RETURN FALSE;
END IsInternalCmd;
PROCEDURE WriteCmd (VAR cmd: OneCommand;
VAR cmdDataDa : BOOLEAN): BOOLEAN;
VAR pCmd : pOneCommand;
BEGIN
IF IsInternalCmd (cmd)
THEN
(* Speicher freigeben *)
IF cmd.hasParms
THEN
DeleteSimpleList (cmd.cmdParms, TRUE, delParam);
END;
IF cmd.cmdHelp # NIL
THEN
DEALLOCATE (cmd.cmdHelp, 0);
END;
v.bool := FALSE;
ELSE
ALLOCATE (pCmd, TSIZE (OneCommand));
IF pCmd = NIL
THEN
RETURN FALSE
END;
(* Inhalt kopieren *)
pCmd^ := cmd;
pCmd^.selected := FALSE;
(* An Liste anhngen *)
Lists.AppendEntry (cmds, pCmd, v.bool);
END;
MagicStrings.Assign ("", cmd.cmdName);
MagicStrings.Assign ("", cmd.cmdGroup);
cmd.cmdVersion := 0;
cmd.hasParms := FALSE;
cmd.cmdHelp := NIL;
cmdDataDa := FALSE;
RETURN ~v.bool;
END WriteCmd;
PROCEDURE compITK (p1, p2: ADDRESS): BOOLEAN;
VAR pA1, pA2 : POINTER TO pOneCommand;
itk1, itk2 : pOneCommand;
BEGIN
pA1 := p1;
pA2 := p2;
itk1 := pA1^;
itk2 := pA2^;
IF Strings.StrEqual (itk1^.cmdGroup, itk2^.cmdGroup)
THEN
RETURN Strings.Compare (itk1^.cmdName, itk2^.cmdName) = Strings.less;
ELSE
RETURN Strings.Compare (itk1^.cmdGroup, itk2^.cmdGroup) = Strings.less;
END;
END compITK;
PROCEDURE SortList (VAR l : Lists.List; compProc: QuickSort.compProc); (* exported *)
(* sortiert die Gruppenliste *)
VAR count : CARDINAL;
sort : POINTER TO ARRAY [0..$FFFF] OF ADDRESS;
i : CARDINAL;
adr : ADDRESS;
BEGIN
count := Lists.NoOfEntries (l);
IF count = 0 THEN RETURN END;
ALLOCATE (sort, LONG(count) * TSIZE (ADDRESS));
IF sort = NIL THEN RETURN END;
Lists.ResetList (l);
FOR i := 0 TO count-1 DO
sort^[i] := Lists.NextEntry (l);
END;
v.bool := QuickSort.sortIt (0, count-1, sort^, compProc, TSIZE (ADDRESS), QuickSort.noBreak);
(* Liste wieder zurckbernehmen *)
Lists.ResetList (l);
FOR i := 0 TO count-1 DO
adr := Lists.NextEntry (l);
Lists.RemoveEntry (l, v.bool);
END;
Lists.ResetList (l);
FOR i := 0 TO count - 1 DO
Lists.AppendEntry (l, sort^[i], v.bool);
END;
DEALLOCATE (sort, 0);
END SortList;
PROCEDURE SortITK();
BEGIN
SortList (cmds, compITK);
END SortITK;
PROCEDURE ParseITK(file: mtTextfiles.TEXTFILE): BOOLEAN;
VAR cDataType,
cConstant : CatTypes.String255;
newPtr : MidTextPtr;
cParam : OneParam;
cEnum : OneEnum;
cCmd : OneCommand;
cmdDataDa : BOOLEAN;
enumDataDa : BOOLEAN;
paramDataDa : BOOLEAN;
pos : CARDINAL;
scrap : CatTypes.String255;
cLineType : CHAR;
BEGIN
paramDataDa := FALSE;
enumDataDa := FALSE;
cmdDataDa := FALSE;
cCmd.cmdHelp := NIL;
cCmd.hasParms := FALSE;
MagicStrings.Assign ("", cCmd.cmdGroup);
cParam.paramHelp := NIL;
cParam.hasEnums := FALSE;
WHILE ~mtTextfiles.EndofText (file) DO
mtTextfiles.ReadLine (file, scrap);
mtTextfiles.ReadLn (file);
(* Erstes Zeichen extrahieren und lschen *)
cLineType := scrap[0];
MagicStrings.Delete (scrap, 0, 1);
CASE cLineType OF
'#' : (* ID des Kommandos *)
IF enumDataDa
THEN
IF ~WriteEnumData (cParam, cEnum, enumDataDa)
THEN
RETURN FALSE;
END;
END;
IF paramDataDa
THEN
IF ~WriteParam(cConstant, cDataType, cParam, cCmd, paramDataDa)
THEN
RETURN FALSE;
END;
END;
IF cmdDataDa
THEN
IF ~WriteCmd (cCmd, cmdDataDa)
THEN
RETURN FALSE;
END;
END;
pos := 0;
cCmd.cmdIdent := StrConv.StrToInt (scrap, pos, v.bool);
cmdDataDa := TRUE; |
'N' : (* Name des Kommandos *)
MagicStrings.Assign (scrap, cCmd.cmdName); |
'V' : (* Version des Kommandos *)
pos := 0;
cCmd.cmdVersion := StrConv.StrToInt (scrap, pos, v.bool); |
'G' : (* Gruppe des Kommandos *)
MagicStrings.Assign (scrap, cCmd.cmdGroup); |
'H' : IF cCmd.cmdHelp = NIL
THEN
ALLOCATE (cCmd.cmdHelp, LENGTH(scrap)+1);
IF cCmd.cmdHelp # NIL
THEN
MagicStrings.Assign (scrap, cCmd.cmdHelp^);
ELSE
RETURN FALSE;
END;
ELSE
ALLOCATE (newPtr, LENGTH (cCmd.cmdHelp^)+LENGTH (scrap) + 2);
IF newPtr # NIL
THEN
(* String zusammensetzen *)
MagicStrings.Assign (cCmd.cmdHelp^, newPtr^);
MagicStrings.Append (" ", newPtr^);
MagicStrings.Append (scrap, newPtr^);
DEALLOCATE (cCmd.cmdHelp, 0);
cCmd.cmdHelp := newPtr;
ELSE
RETURN FALSE;
END;
END; |
'T' : (* Kommandotyp *)
CASE scrap[0] OF
'K' : cCmd.cmdType := tcConfig; |
'E' : cCmd.cmdType := tcSingle; |
'B' : cCmd.cmdType := tcMultiple; |
ELSE
cCmd.cmdType := tcSingle;
END; |
'C' : (* Konstanter Syntax-Teil, neuer Parameter *)
IF enumDataDa
THEN
IF ~WriteEnumData (cParam, cEnum, enumDataDa)
THEN
RETURN FALSE;
END;
END;
IF paramDataDa
THEN
IF ~WriteParam(cConstant, cDataType, cParam, cCmd, paramDataDa)
THEN
RETURN FALSE;
END;
ELSE
Lists.CreateList (cCmd.cmdParms, v.bool);
IF v.bool
THEN
RETURN FALSE;
END;
cCmd.hasParms := TRUE;
END;
MagicStrings.Assign (scrap, cConstant);
paramDataDa := TRUE; |
'F' : (* Variabler Parameter, Datentyp *)
IF enumDataDa
THEN
IF ~WriteEnumData (cParam, cEnum, enumDataDa)
THEN
RETURN FALSE;
END;
END;
IF paramDataDa
THEN
IF ~WriteParam(cConstant, cDataType, cParam, cCmd, paramDataDa)
THEN
RETURN FALSE;
END;
ELSE
Lists.CreateList (cCmd.cmdParms, v.bool);
IF v.bool
THEN
RETURN FALSE;
END;
cCmd.hasParms := TRUE;
END;
MagicStrings.Assign (scrap, cDataType);
IF ~ParseDataType (cDataType, cParam)
THEN
lastCmd := cCmd.cmdIdent;
RETURN FALSE;
END;
paramDataDa := TRUE; |
(* Einzelne Teile eines Parameters *)
'K' : (* Name des Parameters *)
MagicStrings.Assign (scrap, cParam.paramName); |
'D' : (* Defaultwert des Parameters *)
MagicStrings.Assign (scrap, cParam.paramDflt); |
'L' : (* Hilfe zu einem Parameter *)
IF cParam.paramHelp = NIL
THEN
ALLOCATE (cParam.paramHelp, LENGTH(scrap)+1);
IF cParam.paramHelp # NIL
THEN
MagicStrings.Assign (scrap, cParam.paramHelp^);
ELSE
RETURN FALSE;
END;
ELSE
ALLOCATE (newPtr, LENGTH (cParam.paramHelp^)+LENGTH (scrap) + 2);
IF newPtr # NIL
THEN
(* String zusammensetzen *)
MagicStrings.Assign (cParam.paramHelp^, newPtr^);
MagicStrings.Append (" ", newPtr^);
MagicStrings.Append (scrap, newPtr^);
DEALLOCATE (cParam.paramHelp, 0);
cParam.paramHelp := newPtr;
ELSE
RETURN FALSE;
END;
END; |
'A' : (* Aufzhlungsteil des Parameters *)
IF enumDataDa
THEN
IF ~WriteEnumData (cParam, cEnum, enumDataDa)
THEN
RETURN FALSE;
END;
ELSE
Lists.CreateList (cParam.paramEnum, v.bool);
IF v.bool
THEN
RETURN FALSE;
END;
cParam.hasEnums := TRUE;
END;
MagicStrings.Assign (scrap, cEnum.enumValue);
enumDataDa := TRUE; |
'B' : (* Kurzbeschreibung eines Enumwertes *)
MagicStrings.Assign (scrap, cEnum.enumName); |
ELSE
END;
END;
IF enumDataDa
THEN
IF ~WriteEnumData (cParam, cEnum, enumDataDa)
THEN
RETURN FALSE;
END;
END;
IF paramDataDa
THEN
IF ~WriteParam(cConstant, cDataType, cParam, cCmd, paramDataDa)
THEN
RETURN FALSE;
END;
END;
IF cmdDataDa
THEN
IF ~WriteCmd (cCmd, cmdDataDa)
THEN
RETURN FALSE;
END;
END;
(* Jetzt noch ITK sortieren *)
SortITK ();
RETURN TRUE;
END ParseITK;
PROCEDURE InitCmdList (): BOOLEAN;
VAR file : mtTextfiles.TEXTFILE;
fname : CatTypes.String255;
BEGIN
Lists.CreateList (cmds, v.bool);
IF v.bool
THEN
MTE.noMemAlert();
RETURN FALSE;
END;
IF ~Infofiles.GetInfoFilename ('ITK',fname)
THEN
MTE.info (noITKAlert);
RETURN FALSE;
END;
IF mtTextfiles.OpenTextfile (fname, mtTextfiles.READ, 32767, file)
THEN
globErr := errMemErr;
IF ~ParseITK (file)
THEN
mtTextfiles.CloseTextfile (file);
CASE globErr OF
errMemErr : MTE.noMemAlert(); |
errDataType : MTE.numAlert (lastCmd, eDataType); |
ELSE
MTE.info (eUnknown);
END;
(* Bisher allozierten Kram wieder freigeben *)
FreeCmdList();
RETURN FALSE;
END;
mtTextfiles.CloseTextfile (file);
ELSE
MTE.InfoAlert (MTE.noFile1, fname, MTE.noFile4);
RETURN FALSE;
END;
RETURN TRUE;
END InitCmdList;
PROCEDURE FreeCmdList ();
BEGIN
(* Liste wieder entfernen *)
DeleteSimpleList (cmds, TRUE, delCmd);
END FreeCmdList;
(* Userinterface *)
PROCEDURE lineToStr (entry, env : ADDRESS; VAR str : ARRAY OF CHAR);
VAR pCmd : pOneCommand;
BEGIN
pCmd := entry;
IF pCmd = NIL THEN RETURN END;
MagicStrings.Assign (pCmd^.cmdName, str);
END lineToStr;
PROCEDURE selEntry (entry, env: ADDRESS; line : INTEGER): BOOLEAN;
VAR pCmd : pOneCommand;
BEGIN
pCmd := entry;
IF pCmd = NIL THEN RETURN FALSE END;
pCmd^.selected := ~pCmd^.selected;
RETURN FALSE;
END selEntry;
PROCEDURE isSelected (entry, env : ADDRESS) : BOOLEAN;
VAR pCmd : pOneCommand;
BEGIN
pCmd := entry;
IF pCmd = NIL THEN RETURN FALSE END;
RETURN pCmd^.selected;
END isSelected;
PROCEDURE isEnabled (entry, env : ADDRESS) : BOOLEAN;
BEGIN
RETURN TRUE
END isEnabled;
PROCEDURE countEntries ( l : ADDRESS; VAR ll: LONGINT; VAR ww: INTEGER);
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
ww := globalLength * mtAppl.CharWidth;
ll := VAL (LONGINT, Lists.NoOfEntries (lp^));
END countEntries;
VAR tr : mtUtils.tObjcTree;
mTree : ARRAY [0..1] OF MagicAES.OBJECT;
mTed : MagicAES.TEDINFO;
mText : ARRAY [0..255] OF CHAR;
PROCEDURE drawCmdEntry (entry, env : ADDRESS; x, y : INTEGER;
offset : INTEGER; clip : GrafBase.Rectangle);
CONST spaceString = " ";
VAR pCmd : pOneCommand;
BEGIN
tr^[0].obX := x;
tr^[0].obY := y;
IF entry # NIL
THEN
(* Jetzt hier den String fr den Gruppennamen zusammenbauen *)
pCmd := entry;
mtUtils.SetObjcString (tr, 0, pCmd^.cmdName);
mtUtils.SetState (tr, 0, MagicAES.SELECTED, isSelected (entry, env));
ELSE
mtUtils.SetObjcString (tr, 0, spaceString);
mtUtils.SetState (tr, 0, MagicAES.SELECTED, FALSE);
END;
MagicAES.ObjcDraw (tr, 0, 8, clip);
END drawCmdEntry;
PROCEDURE itkButton (tree: ADDRESS; private: ADDRESS; button: INTEGER;
mx, my : INTEGER; kstate: BITSET; clicks: INTEGER): BOOLEAN;
VAR str: CatTypes.String255;
r : GrafBase.Rectangle;
pCmd: pOneCommand;
help : Lists.List;
BEGIN
button := INTEGER(BITSET(button) - {15});
mtUtils.ExclState(tree, button, MagicAES.SELECTED);
(* Jetzt mal nachsehen, was das fr ein Button ist.
* Wenn es OK oder Abbruch ist, dann gehen wir raus
*)
pCmd := private;
IF (button = helpButIdx)
THEN
IF BuildHelp (pCmd, help)
THEN
CatHelp.DoExternalHelp (help);
END;
WinDials.WinDialDraw (tree, button, 1, r, FALSE);
RETURN FALSE;
ELSIF (button = okButIdx)
THEN
(* Valid-Check der einzelnen Elemente *)
v.bool := GetValues (pCmd, FALSE, FALSE);
IF ~v.bool
THEN
WinDials.WinDialDraw (tree, button, 1, r, FALSE);
END;
RETURN v.bool;
ELSIF (button = previewButIdx)
THEN
(* Valid-Check der einzelnen Elemente *)
v.bool := GetValues (pCmd, FALSE, TRUE);
WinDials.WinDialDraw (tree, button, 1, r, FALSE);
RETURN FALSE;
ELSIF (button = cancelButIdx)
THEN
RETURN TRUE
ELSE
(* User oder Gruppenbutton *)
MagicStrings.Assign ("", str);
IF mtUtils.InState (tree, button, Bit13)
THEN
(* Userselect *)
mtUtils.ObjcString (tree, button+1, str);
IF ListHelp.SelectName (str)
THEN
mtUtils.SetObjcString (tree, button+1, str);
END;
ELSIF mtUtils.InState (tree, button, Bit14)
THEN
(* Gruppenselect nur fr Chef *)
mtUtils.ObjcString (tree, button+1, str);
ListHelp.SetLastGroup (str);
IF ListHelp.SelectGroup (str, v.card, FALSE, FALSE, FALSE, ListHelp.gsmChief)
THEN
mtUtils.SetObjcString (tree, button+1, str);
END;
ELSIF mtUtils.InState (tree, button, Bit15)
THEN
(* Gruppenselect *)
mtUtils.ObjcString (tree, button+1, str);
ListHelp.SetLastGroup (str);
IF ListHelp.SelectGroup (str, v.card, FALSE, FALSE, FALSE, ListHelp.gsmOther)
THEN
mtUtils.SetObjcString (tree, button+1, str);
WinDials.WinEditChanged (tree, button+1);
END;
ELSE
RETURN FALSE;
END;
WinDials.WinDialDraw (tree, button, 1, r, FALSE);
RETURN FALSE;
END;
RETURN FALSE;
END itkButton;
PROCEDURE itkGetSetValues (tree: ADDRESS; private: ADDRESS;
set: BOOLEAN; exit: INTEGER);
VAR pCmd: pOneCommand;
BEGIN
IF ~set
THEN
IF exit = okButIdx
THEN
pCmd := private;
v.bool := GetValues (pCmd, TRUE, FALSE);
END;
END;
END itkGetSetValues;
PROCEDURE HandleCommand (pCmd: pOneCommand);
VAR exit : INTEGER;
r : GrafBase.Rectangle;
BEGIN
BuildTree (pCmd);
IF ~WinDials.OpenWinDial (theTree, TRUE,
itkGetSetValues,
itkGetSetValues,
itkButton,
WinDials.defDraw,
"",
pCmd)
THEN
MTE.noWinDialAlert();
RemoveTree ();
FreeCmdList ();
RETURN
END;
(* Leider ein modaler Dialog, da nicht reentrant *)
WinDials.WinDialHandleEvents();
RemoveTree ();
FreeCmdList ();
END HandleCommand;
PROCEDURE setAndGetCmdValues (tree: ADDRESS; private: ADDRESS; set: BOOLEAN; exitBut: INTEGER);
VAR pCmd : pOneCommand;
pInt : POINTER TO INTEGER;
BEGIN
IF ~set
THEN
pInt := private;
pInt^ := exitBut;
END;
END setAndGetCmdValues;
PROCEDURE doItkHelp (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
BEGIN
CatHelp.DoHelp (CatHelp.itkhelp);
mtUtils.SetState (CmdBox, obj, MagicAES.SELECTED, FALSE);
WinDials.WinDialDraw (CmdBox, obj, 1, v.r, FALSE);
draw := FALSE;
exit := FALSE;
END doItkHelp;
PROCEDURE SelectCmd (): BOOLEAN;
VAR exit : INTEGER;
specials : ARRAY [0..1] OF ListDl.specialButHdler;
r : GrafBase.Rectangle;
dialHandler: ListDl.ldHandler;
pCmd : pOneCommand;
BEGIN
IF ~InitCmdList()
THEN
RETURN FALSE;
END;
Lists.ResetList (cmds);
pCmd := Lists.NextEntry (cmds);
globalLength := 0;
WHILE pCmd # NIL DO
globalLength := BinOps.HigherInt (INTEGER(LENGTH(pCmd^.cmdName)), globalLength);
pCmd := Lists.NextEntry (cmds);
END;
INC (globalLength, 2);
(* Objektadresse holen *)
CmdBox := MausTauschrsc.TreeAddr^[MausTauschrsc.cmdbox];
specials[0].objc := MausTauschrsc.chelp;
specials[0].proc := doItkHelp;
(* Jetzt das Object zusammenbauen *)
mtUtils.CalcArea (CmdBox, MausTauschrsc.ccmdbox, r);
globalLength := BinOps.HigherInt (globalLength, r.w DIV mtAppl.CharWidth);
(* Objectadresse holen *)
tr := MausTauschrsc.TreeAddr^[MausTauschrsc.listtxt];
Block.Copy (tr, TSIZE(MagicAES.OBJECT), ADR(mTree));
Block.Copy (tr^[0].obSpec.TedPtr, TSIZE(MagicAES.TEDINFO), ADR(mTed));
mTree[0].obSpec.TedPtr := ADR(mTed);
mTree[0].obSpec.TedPtr^.tePtext := ADR (mText);
tr := ADR (mTree);
tr^[0].obSpec.TedPtr^.teTxtlen := globalLength;
tr^[0].obWidth := globalLength * mtAppl.CharWidth;
mtUtils.SetState (tr, 0, MagicAES.SELECTED, FALSE);
mtUtils.SetState (tr, 0, MagicAES.DISABLED, FALSE);
(* WindowDialog vorbereiten *)
ListDl.BuildLdHandler (ADR(cmds),
ListHelp.resetList,
ListHelp.nextEntry,
ListHelp.prevEntry,
countEntries,
isEnabled, selEntry,
lineToStr, isSelected,
drawCmdEntry,
0, mtAppl.CharHeight,
mtAppl.CharWidth, globalLength * mtAppl.CharWidth,
dialHandler);
(* ListWinDialog ffnen *)
IF ListDl.WinListDial (CmdBox, ListDl.ldElemSet{ListDl.ldArrows, ListDl.ldSelect, ListDl.ldDoubleExit, ListDl.ldModal},
dialHandler,
MausTauschrsc.ccmdbox,
MausTauschrsc.ccmdback,
MausTauschrsc.cok,
MausTauschrsc.ccancel,
ADR(exit), MausTauschrsc.cok,
-1,
ListDl.dummyInLoop,
specials,
1,
ListDl.dummyCheckExit,
setAndGetCmdValues,
setAndGetCmdValues,
pCmd)
THEN
IF (exit = MausTauschrsc.cok) & (pCmd # NIL)
THEN
HandleCommand (pCmd);
END;
END;
FreeCmdList();
RETURN TRUE;
END SelectCmd;
(*$Z-*)
PROCEDURE GetVersion (elem, int: ADDRESS): BOOLEAN;
VAR pInt : POINTER TO INTEGER;
pCmd : pOneCommand;
BEGIN
pInt := int;
pCmd := elem;
RETURN (pCmd # NIL) & (pCmd^.cmdIdent = pInt^);
END GetVersion;
(*$Z+*)
PROCEDURE GetCmdVersion (cmd: INTEGER; VAR version: INTEGER): BOOLEAN;
VAR found: BOOLEAN;
pCmd : pOneCommand;
BEGIN
Lists.ScanEntries (cmds, Lists.forward, GetVersion, ADR(cmd), found);
IF found
THEN
pCmd := Lists.CurrentEntry (cmds);
version := pCmd^.cmdVersion;
END;
RETURN found;
END GetCmdVersion;
END DoITK.